home *** CD-ROM | disk | FTP | other *** search
- Path: cs.tu-berlin.de!news
- From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
- Newsgroups: comp.lang.c++
- Subject: Re: DESPERATE with Borland C++ 4.5 compiler
- Date: 28 Feb 1996 00:43:07 GMT
- Organization: Technical University of Berlin, Germany
- Message-ID: <4h08er$op5@news.cs.tu-berlin.de>
- NNTP-Posting-Host: 130.149.17.236
- Mime-Version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-Encoding: 8bit
-
- Ali Lattunen <Ali.Lattunen@vtt.fi> writes:
- >
- > Still the same problem:
- >
- > Linker recognizes only one instance of template class non-inline member
- > functions. If I have two template class instancies of different user
- > defined type as my class members, e.g.,
- >
- > class MyClass {
- > ..
- > TemplateClass<X> XMember;
- > TemplateClass<Y> YMember;
- > };
- >
- > member functions TemplateClass<Y>::XXX that are not inline are not
- > recognized by the linker.
- >
- > If I declare them inline, the linker works fine even if the compiler
- > warns that functions cannot be expanded inline due to while-statements
- > inside the function body.
- >
- > How is this done right?
- > How can I avoid using inline functions here?
- >
- > Does Borland have any online user information service?
- >
-
- Well, I've had the same problem. As far as I understand this mess there is a bug
- in the compiler. When you create a template class and then instantiate it the compiler
- has to generate the code for the member functions. Certainly the code has to be placed
- in some module. The "Smart Template" option lets the compiler select the module for the
- code. Probably you can guess... this stupid thing doesn't generate the code at all ( the
- inline functions run since no code needs to be generated - they are inline, aren't they ).
- The only solution I have found is to compile one module with the -Jgd ( Global Templates )
- option and the others with the -Jgx ( External Templates ) option. A nice side effect is
- that you cannot use precompiled headers if these options are specified in the makefile or
- in the project. So you have to use #pragma's after the #include's and instantiate ALL of
- your template classes in ONE module or cast all those #pragma's all over your source...
- it's really a mess but it works.
- By the way, there is one thing I don't understand. The first time I encountered this problem
- I tried to compile some of the example files which deal with template and they didn't run
- either. Now tell me, am I doing something wrong or don't these guys test their examples at all?
-
- Bye
-
- Roman
-